package com.pengpeng.android.dao;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class SuperDao {
	

	protected  SQLiteDatabase sqlitedb=null;
	private  String DBNAME="/sdcard/pengpengDB.db";
	
	protected void openDatabase()
	{
		sqlitedb=SQLiteDatabase.openOrCreateDatabase(DBNAME, null);
	}//openDatabase
	
     protected void closeDatabase()
     {
    	 if(sqlitedb!=null)
    	 {
    		 sqlitedb.close();
    		 sqlitedb=null;
    	 }
     }//closeDatabase

     protected boolean existTable(String tablename)
 	{
 		boolean flag=false;
 		String sqlstr="";
 		Cursor cursor=null;
 		int result=0;
 		sqlstr="select type,name from sqlite_master where type='table' and name='"+tablename+"'";
 		cursor=sqlitedb.rawQuery(sqlstr, null);
 		if(cursor!=null && cursor.getCount()>0)
 		{		
 			flag=true;

 		}
 		cursor.close();
 			
 		return flag;
 	}//existTable
}
